package day018.homework.p2;

public class TicketTest implements Runnable{
    private int ticketNum=100;

    @Override
    public void run() {
        while(true){
            synchronized (TicketTest.class){
                if(ticketNum<=0){
                    break;
                }else{
                    System.out.println(Thread.currentThread().getName()+" 售出一张票，剩余"+(--ticketNum)+"张票");
                    try{
                        Thread.sleep(1000);
                    }catch (InterruptedException e){
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
